package com.lagou.concurrent.demo;

import java.util.concurrent.CyclicBarrier;

public class Main {
    public static void main(String[] args) {
        //每次调用barrier.await(), 就必须让5个线程都执行完这一个阶段的任务，才可以进入到下一个阶段
//        CyclicBarrier barrier = new CyclicBarrier(5);
        CyclicBarrier barrier = new CyclicBarrier(5, new Runnable() {
            @Override
            public void run() {
                System.out.println("该阶段结束");
            }
        });

        for (int i = 0; i < 5; i++) {
            new MyThread("线程-" + (i + 1), barrier).start();
        }

    }
}
